<template>
	<view class="mine">
		<view class="status_bar"><!-- 这里是状态栏 --></view>
		<!-- 头部 -->
		<mine-head ref="head" :token="token" v-if="state" :userdata="userdata"></mine-head>
		<!-- 内容 -->
		<mine-content ref="content" :userdata="userdata"></mine-content>
	</view>
</template>

<script>
	
	import heads from '../../components/mine-head/mine-head.vue'
	import contents from '../../components/mine-content/mine-content.vue'
		export default{
			name:'mine',
			components:{
				contents,
				heads
			},
			 provide: function() {   
				return {
				  istoken: this.istoken
				};
			  },
			data(){
				return{
					token: '',
					state: true,
					userdata: ''
				}
			},
			onShow() {
				this.token = uni.getStorageSync('token') ? true : false
				if(this.token) {
					this.getdata()
				}
			},
			watch: {
				'token': function() {
					this.state = false
					setTimeout(() => {
						this.state = true
					},60)
				}
			},
			methods: {
				getdata() {
					// 得到当前用户信息
					this.$api.sendRequest({
						url: this.$url.MINE_userId,
						success: res => {
							this.userdata = res.data.welcome
							console.log(1, this.userdata)
						}
					});
				},
				istoken() {
					return this.token
				}
			}
		}
</script>
